/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package SysAguas.modelo;

import java.io.Serializable;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

/**
 *
 * @author Heitor
 */
@Entity
@Table(name="telefone")
public class Telefone implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;
    @Column(name ="ddd")
    private String ddd;
    @Column(name ="numero")
    private String numero;

    @ManyToOne(cascade=CascadeType.MERGE)
    @JoinColumn(name="id_Hospede")
    private Hospede hospede;

    @ManyToOne(cascade=CascadeType.MERGE)
    @JoinColumn(name="id_Pousada")
    private Pousada pousadaT;
   

    public Telefone() {
    }

    public Telefone(String ddd, String numero) {
        this.ddd = ddd;
        this.numero = numero;
    }

    public String getDdd() {
        return ddd;
    }

    public void setDdd(String ddd) {
        this.ddd = ddd;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Pousada getPousadaT() {
        return pousadaT;
    }

    public void setPousadaT(Pousada pousadaT) {
        this.pousadaT = pousadaT;
    }
    

    public String getNumero() {
        return numero;
    }

    public void setNumero(String numero) {
        this.numero = numero;
    }
    /*public String setTudoJunto(String ddd, String numero){
    String toReturn = ddd+"-"+numero+"";
    return toReturn;
    }*/

    public Hospede getHospede() {
        return hospede;
    }

    public void setHospede(Hospede hospede) {
        this.hospede = hospede;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Telefone other = (Telefone) obj;
        if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 79 * hash + (this.id != null ? this.id.hashCode() : 0);
        return hash;
    }
    
    /*public void setCamposTelefone(String telefone){

    for (int i = 0; i < telefone.length(); i++) {
    if(telefone.charAt(i) == '-'){
    this.ddd = telefone.substring(0, i-1);
    this.numero = telefone.substring(i+1, 14);

    }

    }

    }*/


}
